#****************************************************************************
#
# Makefile for StarCore.
# www.srplab.com
#****************************************************************************
DEBUG          := NO
PROFILE        := NO
#****************************************************************************
CC     := gcc
CXX    := g++
LD     := g++
AR     := ar
RANLIB := ranlib

DEBUG_CFLAGS     := -Wall -Wno-format -g -DDEBUG -DENV_LINUX
RELEASE_CFLAGS   := -Wall -Wno-unknown-pragmas -Wno-format -O3 -DENV_LINUX

LIBS	:= -ldl -lpthread -lrt

DEBUG_CXXFLAGS   := ${DEBUG_CFLAGS} 
RELEASE_CXXFLAGS := ${RELEASE_CFLAGS}

DEBUG_LDFLAGS    := -g
RELEASE_LDFLAGS  :=

ifeq (YES, ${DEBUG})
   CFLAGS       := ${DEBUG_CFLAGS}
   CXXFLAGS     := ${DEBUG_CXXFLAGS}
   LDFLAGS      := ${DEBUG_LDFLAGS}
else
   CFLAGS       := ${RELEASE_CFLAGS}
   CXXFLAGS     := ${RELEASE_CXXFLAGS}
   LDFLAGS      := ${RELEASE_LDFLAGS}
endif

ifeq (YES, ${PROFILE})
   CFLAGS   := ${CFLAGS} -pg -O3
   CXXFLAGS := ${CXXFLAGS} -pg -O3
   LDFLAGS  := ${LDFLAGS} -pg
endif

#****************************************************************************
# Makefile code common to all platforms
#****************************************************************************

CFLAGS   := ${CFLAGS}   ${DEFS}
CXXFLAGS := ${CXXFLAGS} ${DEFS}

#****************************************************************************
# include source and paths
#****************************************************************************

INCS_T := ../include ../include/ctrl ../font_freetype /usr/include/freetype2
INCS   = $(addprefix -I,$(INCS_T))

AGGLIB_CXXSRCS += $(wildcard ../src/*.cpp)
AGGLIB_CXXSRCS += $(wildcard ../src/ctrl/*.cpp)
AGGLIB_CXXSRCS += $(wildcard ../font_freetype/*.cpp)

#****************************************************************************
AGGLIB_CXXOBJS := $(AGGLIB_CXXSRCS:%.cpp=%.o)
AGGLIB_COBJS   := 

#****************************************************************************
CXXOBJS := ${AGGLIB_CXXOBJS}
COBJS := ${AGGLIB_COBJS}

LIB_AGGLIB_OBJS := ${AGGLIB_CXXOBJS} ${AGGLIB_COBJS} 

#****************************************************************************
# Targets of the build
#****************************************************************************
OBJS_PATH = .

LIB_AGGLIB := ${OBJS_PATH}/agglib.a

all: ${LIB_AGGLIB}

#****************************************************************************
# Output
#****************************************************************************

${LIB_AGGLIB} : ${LIB_AGGLIB_OBJS}	
	${AR} r $@ ${LIB_AGGLIB_OBJS}
	${RANLIB} $@

#****************************************************************************
# common rules
#****************************************************************************

${CXXOBJS} :
	${CXX} -fPIC ${CXXFLAGS} ${INCS} $< -o $@ -c $*.cpp

${COBJS} : 
	${CC} -fPIC ${CFLAGS} ${INCS} -o $@ -c $*.c

clean:
	-rm -f core ${CXXOBJS} ${COBJS} ${LIB_AGGLIB}

    

